package edu.spec.test.controller;

import edu.spec.sys.model.User;
import edu.spec.sys.model.dto.MvcReturn;
import edu.spec.test.service.iface.ITestUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author       : MadFrog
 * Date         : 2018/10/15 20:31
 * Description  :
 */
@Controller
public class LoginController {

    @Autowired
    private ITestUserService userService;

    @ResponseBody
    @RequestMapping("/login")
    public MvcReturn login(String username, String password){
        User dbuser=userService.loadUserByName(username);
        String dbpassword=dbuser.getPassword();
        if(dbpassword.equals(password)){
            return new MvcReturn(true, "登录成功");
        } else {
            return new MvcReturn(false, "密码错误");
        }

    }

}
